<?php

//menu
function secMenu($id,$active)
{
	global $smarty, $db;
	$li = "";
	$select = $db->select();
	$select->from('menu');
	$select->where('menu_id = ?',$id);
	$count = $db->fetchOne("SELECT COUNT(*) c FROM menu WHERE menu_id = ? ",$id);
	$menu = $db->fetchAll($select);
	for ($i=0;$i<$count;$i++)
	{
		$style="";
		
		if ($i==0){$style='class="firstLi"';}
		elseif($i==$count-1){$style='class="lastLi"';}
		if ($menu[$i]['url'] == $active) {
			$activPre = "<span title=\"".$menu[$i]['title']."\">";
			$activPost = "</span>";
		} else {
			$activPre = "<a href=\"/".$menu[$i]['url'].".html\" title=\"".$menu[$i]['title']."\">";
			$activPost = "</a>";
		}
		
		$li .="<li $style>$activPre<span class=\"".$menu[$i]['class']."\">".$menu[$i]['title']."</span>$activPost</li> \n";
		
		
	}
	//echo $li."<br>\n";
	$smarty->assign('menuid',$li);
	$export = $smarty->fetch('secMenu.tpl');
	$smarty->assign('secMenu',$export);
	
	
}
function mainMenu($id,$active)
{
	global $smarty, $db;
	$li = "";
	$select = $db->select();
	$select->from('menu');
	$select->where('menu_id = ?',$id);
	$count = $db->fetchOne("SELECT COUNT(*) c FROM menu WHERE menu_id = ?",$id);
	$menu = $db->fetchAll($select);
	for ($i=0;$i<$count;$i++)
	{

		if ($menu[$i]['url'] == $active) {
			$activPre = "<span title=\"".$menu[$i]['title']."\">";
			$activPost = "</span>";
		} else {
			$activPre = "<a href=\"/".$menu[$i]['url'].".html\" title=\"".$menu[$i]['title']."\">";
			$activPost = "</a>";
		}
		
		$li .="<li>$activPre".$menu[$i]['title']."$activPost</li> \n";
		
		
	}
	//echo $li."<br>\n";
	$smarty->assign('menuid',$li);
	$export = $smarty->fetch('mainMenu.tpl');
	$smarty->assign('mainMenu',$export);	
}
function leftMenu($id,$active)
{
	global $smarty, $db;
	$li = "";
	$select = $db->select();
	$select->from('menu');
	$select->where('menu_id = ?',$id);
	$count = $db->fetchOne("SELECT COUNT(*) c FROM menu WHERE menu_id = ?",$id);
	$menu = $db->fetchAll($select);
	for ($i=0;$i<$count;$i++)
	{

		if ($menu[$i]['url'] == $active) {
			$activPre = " class=\"active\"><span title=\"".$menu[$i]['title']."\">";
			$activPost = "</span>";
		} else {
			$activPre = "><a href=\"/".$menu[$i]['url'].".html\" title=\"".$menu[$i]['title']."\">";
			$activPost = "</a>";
		}
		
		$li .="<li$activPre".$menu[$i]['title']."$activPost</li> \n";
		
		
	}
	//echo $li."<br>\n";
	$smarty->assign('menuid',$li);
	$export = $smarty->fetch('leftMenu.tpl');
	$smarty->assign('leftMenu',$export);	
}
function picMenu($id)
{
	global $smarty, $db;
	$li = "";
	$select = $db->select();
	$select->from('menu');
	$select->where('menu_id = ?',$id);
	$count = $db->fetchOne("SELECT COUNT(*) c FROM menu WHERE menu_id = ?",$id);
	$menu = $db->fetchAll($select);
	for ($i=0;$i<$count;$i++)
	{
		$li .="<li class=\"".$menu[$i]['class']."\"><a href=\"/".$menu[$i]['url']."\" title=\"".$menu[$i]['desc']."\"></a></li> \n";
	}
	//echo $li."<br>\n";
	$smarty->assign('menuid',$li);
	$export = $smarty->fetch('picMenu.tpl');
	$smarty->assign('picMenu',$export);	
}

?>